﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:converter="clr-namespace:De06B_Nhom02.Converters"
             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
             xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
             x:Class="De06B_Nhom02.Controls.NodeControl"
             mc:Ignorable="d"
             Width="300"
             Height="300"
             d:DesignHeight="300"
             d:DesignWidth="300">
    <UserControl.Resources>
        <converter:NodeTypeToBrushConverter x:Key="NodeTypeToBrushConverter" />
        <converter:NodeTypeToVisibilityConverter x:Key="NodeTypeToVisibilityConverter" />
    </UserControl.Resources>
    <UserControl.ContextMenu>
        <ContextMenu>
            <MenuItem Header="Set start">
                <MenuItem Header="0"
                          Command="{Binding SetStartCommand}"
                          CommandParameter="0" />
                <MenuItem Header="1"
                          Command="{Binding SetStartCommand}"
                          CommandParameter="1" />
                <MenuItem Header="2"
                          Command="{Binding SetStartCommand}"
                          CommandParameter="2" />
                <MenuItem Header="3"
                          Command="{Binding SetStartCommand}"
                          CommandParameter="3" />
                <MenuItem Header="4"
                          Command="{Binding SetStartCommand}"
                          CommandParameter="4" />
            </MenuItem>
            <MenuItem Header="Set goal">
                <MenuItem Header="0"
                          Command="{Binding SetGoalCommand}"
                          CommandParameter="0" />
                <MenuItem Header="1"
                          Command="{Binding SetGoalCommand}"
                          CommandParameter="1" />
                <MenuItem Header="2"
                          Command="{Binding SetGoalCommand}"
                          CommandParameter="2" />
                <MenuItem Header="3"
                          Command="{Binding SetGoalCommand}"
                          CommandParameter="3" />
                <MenuItem Header="4"
                          Command="{Binding SetGoalCommand}"
                          CommandParameter="4" />
            </MenuItem>
        </ContextMenu>
    </UserControl.ContextMenu>
    <UserControl.RenderTransform>
        <ScaleTransform CenterX="0"
                        CenterY="0"
                        ScaleX="{Binding Scale}"
                        ScaleY="{Binding Scale}" />
    </UserControl.RenderTransform>
    <Grid MouseMove="Grid_MouseMove">
        <Polygon Fill="{Binding Node.Type, Converter={StaticResource NodeTypeToBrushConverter}}"
                 Stroke="Black"
                 StrokeThickness="4">
            <Polygon.Points>
                <Point X="0"
                       Y="150" />
                <Point X="75"
                       Y="20.1" />
                <Point X="225"
                       Y="20.1" />
                <Point X="300"
                       Y="150" />
                <Point X="225"
                       Y="279.9" />
                <Point X="75"
                       Y="279.9" />
            </Polygon.Points>
        </Polygon>
        <StackPanel Orientation="Horizontal"
                    HorizontalAlignment="Center"
                    VerticalAlignment="Center">
            <TextBlock FontSize="120"
                       Foreground="Black"
                       Text="{Binding Node.Id}"
                       Visibility="{Binding Node.Type, Converter={StaticResource NodeTypeToVisibilityConverter}}" />
        </StackPanel>
    </Grid>
</UserControl>